package com.ruoyi.swimming.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.swimming.domian.Natatorium;
import com.ruoyi.swimming.domian.News;
import com.ruoyi.swimming.mapper.NatatoriumMapper;
import com.ruoyi.swimming.mapper.NewsMapper;
import com.ruoyi.swimming.service.INewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * 消息Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-07-17
 */
@Service
public class NewsServiceImpl extends ServiceImpl<NewsMapper, News> implements INewsService
{
    @Autowired
    private NewsMapper newsMapper;

    /**
     * 查询消息
     * 
     * @param id 消息ID
     * @return 消息
     */
    @Override
    public News selectNewsById(Long id)
    {
        return newsMapper.selectNewsById(id);
    }

    /**
     * 查询消息列表
     * 
     * @param news 消息
     * @return 消息
     */
    @Override
    public List<News> selectNewsList(News news)
    {
        return newsMapper.selectNewsList(news);
    }

    /**
     * 新增消息
     * 
     * @param news 消息
     * @return 结果
     */
    @Override
    public int insertNews(News news)
    {
        news.setCreateTime(DateUtils.getNowDate());
        return newsMapper.insert(news);
    }

    /**
     * 修改消息
     * 
     * @param news 消息
     * @return 结果
     */
    @Override
    public int updateNews(News news)
    {
        news.setUpdateTime(DateUtils.getNowDate());
        return newsMapper.updateById(news);
    }

    /**
     * 批量删除消息
     * 
     * @param ids 需要删除的消息ID
     * @return 结果
     */
    @Override
    public int deleteNewsByIds(Long[] ids)
    {
        return newsMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除消息信息
     * 
     * @param id 消息ID
     * @return 结果
     */
    @Override
    public int deleteNewsById(Long id)
    {
        return newsMapper.deleteById(id);
    }
}
